#include "Effect.h"

Container<Effect>::Container()
{
	Objects = NULL;
	Count = 0;
	Ref++;
	if(Ref == 1)
	{
		Error = new T;
		strcpy_s(Error->name, NAMELEN, "Error");
	}
	Parent = NULL;
}

Effect & Container<Effect>::operator [] (const Value &Index) const
{
	if(Index.GetType() == AT_INT)
	{
		if( Index.ToInt() < 0 || Index.ToInt() >= Count)
			return *Error;	
		return *Objects[Index.ToInt()];
	}
	else if(Index.GetType() == AT_STRING)
	{
		for(int i = 0; i < Count; i++)
		{
			if(strcmp(Objects[i]->name, Index.name) == 0)
				return *Objects[i];
		}
	}
	return *Error;
}

Effect::Effect()
{
	memset(name, 0, NAMELEN);
}

Effect::Effect(const Effect &Source)
{
	Copy(Source);
}

Effect::~Effect()
{
}

Effect & Effect::operator = (const Effect &Source)
{
	Copy(Source);

	return *this;
}

void Effect::Copy(const Effect &Source)
{
	memcpy(name, Source.name, NAMELEN);
	Attributes = Source.Attributes;
}